<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="AIRAliases.js"></script>
<script src="jquery.js"></script>
<script type="text/javascript">
/*
function onResize(type){
    nativeWindow.startResize(type);
}
*/
function onNativeMove(){
    nativeWindow.startMove();
}
function onNativeClose(){
    nativeWindow.close();
}
var bridgeInterface = {};
bridgeInterface.movefunc = onNativeMove;
bridgeInterface.hideclose = function(hide){
air.trace(hide);
    if (hide){
    $('#close').hide();
    } else {
    $('#close').show();
    }
}
bridgeInterface.trace = function(log){
    air.trace(log);
}
bridgeInterface.ropen = function(url){
    air.navigateToURL(new air.URLRequest(url));
}

function hasver(v1, v2){
  var a1 = v1.split('.'); 
  var a2 = v2.split('.'); 
  do {
     var t1 = Number(a1.shift());
     var t2 = Number(a2.shift());
     if (t1 == t2) continue;
     return (t1>t2)
  } while((a1.length>0) && (a2.length>0));
  return (a1.length>0)
}

function init(){
	$('body').mousedown(onNativeMove);
    var ver = air.NativeApplication.nativeApplication.runtimeVersion;
	if(!hasver(ver, '1.5.2')){
        $('#radio_div').hide();
        $('#low_version').show();
        air.navigateToURL(new air.URLRequest('http://get.adobe.com/air/'));
    }
}
function engageBridge(){
    document.getElementById("sandbox").contentWindow.parentSandboxBridge = bridgeInterface;
}
//$(window).hover(function(){air.trace('over')}, function(){air.trace('out')});
//$(window).mousemove(function(e){air.trace(e.pageX,e.pageY)})
</script>
<style type="text/css">
body{ background: url(shadow.png) }
.header {position: relative; height:20px; }
#close{ display:none; cursor: pointer; position:absolute; top: -3px; left: 393px; height:50px; width:50px; background:url("close.png")}
#radio_div{padding: 20px; }
#low_version{margin: 50px; padding: 15px; background: #ddd; border:1px dashed #999; font-size:12px; line-height: 1.6em; text-align:center;display:none}
</style>
<title>Douban Radio</title>
</head>

<body onload="init()">
<!--<div class = 'header'>
<div id='close' onclick = "onNativeClose()"></div>
</div>
-->
<div id="low_version">本应用需要air 1.5.2以上，请安装最新版的air运行时。
<br/><a href="http://get.adobe.com/air/">http://get.adobe.com/air/</a>
<br/><br/><a href="#" onclick="onNativeClose()">关闭</a>
</div>
<div id="radio_div">
<iframe id="sandbox" width="420" height="186" style="border:0"
        src="http://www.douban.com/radio/"
        documentRoot="app:/"
        sandboxRoot="http://www.douban.com/air/"
        allowCrossDomainXHR="allowCrossDomainXHR"
        ondominitialize="engageBridge()"></iframe>
</div>
</body>
</html>
